package cn.netjava.robo3d;

import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.action.InputActionEvent;
import com.jme.input.action.KeyNodeBackwardAction;
import com.jme.input.action.KeyNodeForwardAction;
import com.jme.input.action.KeyNodeRotateLeftAction;
import com.jme.input.action.KeyNodeRotateRightAction;
import com.jme.scene.Spatial;

/**
 * 主角的键盘映射
 * @author westice
 *
 */
public class Input extends InputHandler {

	private KeyNodeForwardAction forward;
	private KeyNodeBackwardAction backward;
	private KeyNodeRotateRightAction rotateRight;
	private KeyNodeRotateLeftAction rotateLeft;

	public Input(){
		setKeyBindings();

	}

	public InputActionEvent getevent(){
		return event;
	}

	public void setKeyBindings() {
        KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();

        keyboard.set("forward2", KeyInput.KEY_NUMPAD8);
        keyboard.set("backward2", KeyInput.KEY_NUMPAD2);
        keyboard.set("turnRight2", KeyInput.KEY_NUMPAD6);
        keyboard.set("turnLeft2", KeyInput.KEY_NUMPAD4);

        keyboard.set("forward", KeyInput.KEY_UP);
        keyboard.set("backward", KeyInput.KEY_DOWN);
        keyboard.set("turnRight", KeyInput.KEY_RIGHT);
        keyboard.set("turnLeft", KeyInput.KEY_LEFT);

        keyboard.set("caseleft", KeyInput.KEY_A);
        keyboard.set("caseright", KeyInput.KEY_D);

        keyboard.set("test",KeyInput.KEY_NUMPAD4);
        keyboard.set("changeGear", KeyInput.KEY_C);  //更换油门等级
        keyboard.set("firegun", KeyInput.KEY_S);      //火枪
        keyboard.set("shoot", KeyInput.KEY_SPACE); //射击
        keyboard.set("jump",KeyInput.KEY_J);         //跳跃
        keyboard.set("changemode", KeyInput.KEY_V);              //切换观看模式瞄准器
        keyboard.set("showatlas",KeyInput.KEY_M);   //显示小地图
        keyboard.set("showcursor", KeyInput.KEY_O); //显示鼠标

    }

	public void update(float time){
		if ( !isEnabled() ) return; //如果不可用 返回
		super.update(time);

	}

}
